2 * Copyright (c) 2008, The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "android_audio_output_threadsafe_callbacks.h"
18 #include "android_audio_output.h"
20 AndroidAudioOutputThreadSafeCallbackAO::AndroidAudioOutputThreadSafeCallbackAO(void* aObserver,
24 :ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
30 AndroidAudioOutputThreadSafeCallbackAO::~AndroidAudioOutputThreadSafeCallbackAO()
36 OsclReturnCode AndroidAudioOutputThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
38 // In this case, ProcessEvent calls the method of the primary test AO to process the Event
39 if (iObserver != NULL)
41 AndroidAudioOutput* ptr = (AndroidAudioOutput*) iObserver;
42 // Call RunIfNotReady() for the AudioMIO
51 #if PROCESS_MULTIPLE_EVENTS_IN_CALLBACK
52 void AndroidAudioOutputThreadSafeCallbackAO::Run()
55 OsclReturnCode status = OsclSuccess;
56 // Process multiple events in one attempt
59 param = Dequeue(status);
60 if((status == OsclSuccess) || (status == OsclPending))
64 }while(status == OsclSuccess);
67 OsclAny* AndroidAudioOutputThreadSafeCallbackAO::Dequeue(OsclReturnCode &status)
70 OsclProcStatus::eOsclProcError sema_status;
82 param = (Q->pFirst[Q->index_out]).pData;
84 if(Q->index_out == Q->MaxNumElements)
89 // Call PendForExec() only when there are no more elements in the queue
90 // Else, continue in the do-while loop
96 sema_status = RemoteThreadCtrlSema.Signal();
97 if(sema_status != OsclProcStatus::SUCCESS_ERROR)