LCOV - code coverage report
Current view: top level - Core - OOALBufferedSound.m (source / functions) Hit Total Coverage
Test: coverxygen.info Lines: 0 4 0.0 %
Date: 2025-05-28 07:50:54 Functions: 0 0 -

          Line data    Source code
       1           0 : /*
       2             : 
       3             : OOALBufferedSound.m
       4             : 
       5             : 
       6             : OOALBufferedSound - OpenAL sound implementation for Oolite.
       7             : Copyright (C) 2005-2013 Jens Ayton
       8             : 
       9             : Permission is hereby granted, free of charge, to any person obtaining a copy
      10             : of this software and associated documentation files (the "Software"), to deal
      11             : in the Software without restriction, including without limitation the rights
      12             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      13             : copies of the Software, and to permit persons to whom the Software is
      14             : furnished to do so, subject to the following conditions:
      15             : 
      16             : The above copyright notice and this permission notice shall be included in all
      17             : copies or substantial portions of the Software.
      18             : 
      19             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      20             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      21             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      22             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      23             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      24             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      25             : SOFTWARE.
      26             : 
      27             : */
      28             : 
      29             : #import "OOALBufferedSound.h"
      30             : #import "OOALSoundDecoder.h"
      31             : 
      32             : @implementation OOALBufferedSound
      33             : 
      34           0 : - (void)dealloc
      35             : {
      36             :         free(_buffer);
      37             :         _buffer = NULL;
      38             :         DESTROY(_name);
      39             :         
      40             :         [super dealloc];
      41             : }
      42             : 
      43           0 : - (NSString *)name
      44             : {
      45             :         return _name;
      46             : }
      47             : 
      48             : 
      49             : 
      50             : - (id)initWithDecoder:(OOALSoundDecoder *)inDecoder
      51             : {
      52             :         BOOL                                    OK = YES;
      53             :         
      54             :         [OOSound setUp];
      55             :         if (![OOSound isSoundOK] || nil == inDecoder) OK = NO;
      56             :         
      57             :         if (OK)
      58             :         {
      59             :                 self = [super init];
      60             :                 if (nil == self) OK = NO;
      61             :         }
      62             :         
      63             :         if (OK)
      64             :         {
      65             :                 _name = [[inDecoder name] copy];
      66             :                 _sampleRate = [inDecoder sampleRate];
      67             :                 OK = [inDecoder readCreatingBuffer:&_buffer withFrameCount:&_size];
      68             :                 _stereo = [inDecoder isStereo];
      69             :         }
      70             :         
      71             :         if (!OK)
      72             :         {
      73             :                 [self release];
      74             :                 self = nil;
      75             :         }
      76             :         return self;
      77             : }
      78             : 
      79             : 
      80           0 : - (ALuint) soundBuffer
      81             : {
      82             :         ALuint buffer;
      83             :         ALint error;
      84             :         OOAL(alGenBuffers(1,&buffer));
      85             :         if ((error = alGetError()) != AL_NO_ERROR)
      86             :         {
      87             :                 OOLog(kOOLogSoundLoadingError, @"%@", @"Could not create OpenAL buffer");
      88             :                 return 0;
      89             :         }
      90             :         else
      91             :         {
      92             :                 if (!_stereo)
      93             :                 {
      94             :                         alBufferData(buffer,AL_FORMAT_MONO16,_buffer,(ALsizei)_size,_sampleRate);
      95             :                 }
      96             :                 else
      97             :                 {
      98             :                         alBufferData(buffer,AL_FORMAT_STEREO16,_buffer,(ALsizei)_size,_sampleRate);
      99             :                 }
     100             :                 return buffer;
     101             :         }
     102             : }
     103             : 
     104             : @end

Generated by: LCOV version 1.14