Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: Source/platform/audio/HRTFDatabaseLoader.cpp

Issue 685153005: Oilpan: HRTF dababase loader thread should be attached to Oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/audio/HRTFDatabaseLoader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 HRTFDatabaseLoader::HRTFDatabaseLoader(float sampleRate) 65 HRTFDatabaseLoader::HRTFDatabaseLoader(float sampleRate)
66 : m_databaseSampleRate(sampleRate) 66 : m_databaseSampleRate(sampleRate)
67 { 67 {
68 ASSERT(isMainThread()); 68 ASSERT(isMainThread());
69 } 69 }
70 70
71 HRTFDatabaseLoader::~HRTFDatabaseLoader() 71 HRTFDatabaseLoader::~HRTFDatabaseLoader()
72 { 72 {
73 ASSERT(isMainThread()); 73 ASSERT(isMainThread());
74
75 MutexLocker locker(m_lock);
tkent 2014/11/10 06:27:54 Please mention this change in the CL description.
haraken 2014/11/10 06:37:10 Done.
76 waitForLoaderThreadCompletion(); 74 waitForLoaderThreadCompletion();
77 m_hrtfDatabase.clear();
78 } 75 }
79 76
80 void HRTFDatabaseLoader::load() 77 void HRTFDatabaseLoader::load()
81 { 78 {
82 ASSERT(!isMainThread()); 79 ASSERT(!isMainThread());
83 MutexLocker locker(m_lock); 80 m_thread->attachGC();
84 if (!m_hrtfDatabase) { 81
85 // Load the default HRTF database. 82 {
86 m_hrtfDatabase = HRTFDatabase::create(m_databaseSampleRate); 83 MutexLocker locker(m_lock);
84 if (!m_hrtfDatabase) {
85 // Load the default HRTF database.
86 m_hrtfDatabase = HRTFDatabase::create(m_databaseSampleRate);
87 }
87 } 88 }
89
90 m_thread->detachGC();
88 } 91 }
89 92
90 void HRTFDatabaseLoader::loadAsynchronously() 93 void HRTFDatabaseLoader::loadAsynchronously()
91 { 94 {
92 ASSERT(isMainThread()); 95 ASSERT(isMainThread());
93 96
94 MutexLocker locker(m_lock); 97 MutexLocker locker(m_lock);
95 if (!m_hrtfDatabase && !m_databaseLoaderThread) { 98 if (!m_hrtfDatabase && !m_thread) {
96 // Start the asynchronous database loading process. 99 // Start the asynchronous database loading process.
97 m_databaseLoaderThread = adoptPtr(Platform::current()->createThread("HRT F database loader")); 100 m_thread = WebThreadSupportingGC::create("HRTF database loader");
98 m_databaseLoaderThread->postTask(new Task(WTF::bind(&HRTFDatabaseLoader: :load, this))); 101 m_thread->postTask(new Task(WTF::bind(&HRTFDatabaseLoader::load, this))) ;
99 } 102 }
100 } 103 }
101 104
102 bool HRTFDatabaseLoader::isLoaded() 105 bool HRTFDatabaseLoader::isLoaded()
103 { 106 {
104 MutexLocker locker(m_lock); 107 MutexLocker locker(m_lock);
105 return m_hrtfDatabase; 108 return m_hrtfDatabase;
106 } 109 }
107 110
108 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() 111 void HRTFDatabaseLoader::waitForLoaderThreadCompletion()
109 { 112 {
110 m_databaseLoaderThread.clear(); 113 m_thread.clear();
111 } 114 }
112 115
113 } // namespace blink 116 } // namespace blink
114 117
115 #endif // ENABLE(WEB_AUDIO) 118 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/platform/audio/HRTFDatabaseLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698